from django.db import models
from datetime import datetime
# Create your models here.
class User(models.Model):
    id=models.AutoField(primary_key=True, auto_created=True)
    username = models.CharField(max_length=100,unique=True)
    password = models.CharField(max_length=100)
    email = models.EmailField(max_length=100,unique=True)
    def __str__(self):
        return self.username
    class Meta:
        db_table = 'user'


class Post(models.Model):
    id=models.AutoField(primary_key=True, auto_created=True)
    title = models.CharField(max_length=100)
    content = models.TextField()
    time=models.DateTimeField(default=datetime.now)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    def __str__(self):
        return self.title
    class Meta:
        db_table = 'post'